#!/bin/bash
path=$2
helmspace=$1
oriName=$3
dirName=`echo ${oriName%.*}`
jieya=`cd $path | unzip -o $oriName`
if [ "`echo $jieya | grep -e Archive`" ]; then
	kamen=$(helm3 repo list|grep $helmspace)
	if [ -n "$kamen" ]; then
	           cd $path && helm3 push $dirName $helmspace
                   helm3 repo update
		   rm -rf $oriName
		   rm -rf $dirName
	else
	           helm3 repo add $helmspace https://repomanage.rdc.aliyun.com/helm_repositories/$helmspace --username=$4 --password=$5
  		   cd $path && helm3 push $dirName $helmspace   	            helm3 repo update
 		   rm -rf $oriName
		   rm -rf $dirName
	fi
else 
	exit 1;
fi
